<?php
  
    include('./library/conn.php');

    $password = $_REQUEST['password'];
    $phone = $_REQUEST['phone'];

    // 3. 查询手机号是否存在
    $sql = "select * from users where phone='$phone'";
    
    $result = $mysqli->query($sql);

    if($result->num_rows>0){
		echo '{"has":ture,"msg":"手机号已存在"}';
        $mysqli->close(); // 断开连接
        die(); // 终止代码执行
    }else{
		echo '{"has":false,"msg":"手机号可以使用"}';
	}

    // 插入数据
    $insert = "insert into users (password,phone) values ('$password','$phone')";

    $mysqli->query($insert); 
    $mysqli->close();

?>